<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\api\controller;

use think\Db;

/**
 * 可用钱包控制器
 */
class AvailablePurse extends ApiBase
{



        /**
         * 用户线下充值接口
         */
        public function down_line_recharge(){
            return $this->apiReturn($this->logicAvailablePurse->down_line_recharge($this->param));
        }
        /**
         * 总包转出娱乐城接口
         */
        public function transfer_out(){
            return $this->apiReturn($this->logicAvailablePurse->transfer_out($this->param));
        }


        /**
         * 总包转入注册钱包接口
         */
        public function transfer_to_reg_wallet(){
            return $this->apiReturn($this->logicAvailablePurse->transfer_to_reg_wallet($this->param));
        }
        /**
         *注册钱包转入理财包接口
         */
        public function transfer_to_profit_wallet(){
            return $this->apiReturn($this->logicAvailablePurse->transfer_to_profit_wallet($this->param));
        }

        /**
         * 盈利包转入注册钱包接口
         */
        public function profit_to_reg_wallet(){
            return $this->apiReturn($this->logicAvailablePurse->profit_to_reg_wallet($this->param));
        }
        /**
         * 盈利包亏损接口
         */
        public function profit_to_patch(){
            return $this->apiReturn($this->logicAvailablePurse->profit_to_patch($this->param));
        }

     /**
     * 盈利包转入总钱包接口
     */
    public function profit_to_wallet(){
        return $this->apiReturn($this->logicAvailablePurse->profit_to_wallet($this->param));
    }


    /**
     * 理财包转入总钱包接口
     */
    public function financial_to_wallet(){
        return $this->apiReturn($this->logicAvailablePurse->financial_to_wallet($this->param));
    }

    /**
     * 盈利包转入注册钱包接口
     */
    public function financial_to_reg_wallet(){
        return $this->apiReturn($this->logicAvailablePurse->financial_to_reg_wallet($this->param));
    }

    /**
     * 用户转账接口
     */
    public function transfer(){
        return $this->apiReturn($this->logicAvailablePurse->transfer($this->param));
    }

    /**
     * 获取记账本列表
     */
    public function bookkeeping(){

        return $this->apiReturn($this->logicAvailablePurse->bookkeeping($this->param));

    }



    /**
     * 获取心血公式详情
     */
    public function investment_detail(){

        return $this->apiReturn($this->logicAvailablePurse->investment_detail($this->param));

    }

    /**
     * 获取奖金/红利详情
     */
    public function bonus_detail(){

        return $this->apiReturn($this->logicAvailablePurse->bonus_detail($this->param));

    }

    /**
     * 获取配置
     */
    public function get_reward_config(){

        return $this->apiReturn($this->logicAvailablePurse->get_reward_config());

    }
    /**
     * 获取可用钱包转出明细列表
     */
    public function vailable_turnout_log(){

        return $this->apiReturn($this->logicAvailablePurse->vailable_turnout_log($this->param));

    }


    /**
     * 获取可用钱包流水详情
     */
    public function vailable_account_log_detail(){

        return $this->apiReturn($this->logicAvailablePurse->vailable_account_log_detail($this->param));

    }

    /**
     * 获取可用钱包首页详情
     */
    public function vailable_account_index(){
		$token = input("user_token");
		$uid = decoded_user_token($token,'member_id');
		$result = Db::name("user_account")->where(["user_id"=>$uid,"is_wallet"=>2])->select();
		foreach($result as $value){
			$count = Db::name("coin_login_list")->where(["user_id"=>$uid,"mid"=>$value['wallet_id'],"type"=>1])->count();
			if(empty($count)){
				$data['mid'] = $value['wallet_id'];
				$data['type'] = 1;
				$data['create_time'] = time();
				$data['user_id'] = $uid;
				$data['address'] = $value['blockchain_address2'];
				Db::name("coin_login_list")->insert($data);
			}
		}
		
        return $this->apiReturn($this->logicAvailablePurse->vailable_account_index($this->param));

    }

    /**
     * 交易接口
     */
    public function against_trade(){

        return $this->apiReturn($this->logicAvailablePurse->against_trade($this->param));

    }





}
